# Reference: <https://postmarketos.org/devicepkg>
# Maintainer: JustSoup321 <brandonboese@protonmail.com>
# Co-Maintainer: Alper Nebi Yasak <alpernebiyasak@gmail.com>
# Co-Maintainer: Jenneron <jenneron@protonmail.com>
pkgname=device-google-x64cros
pkgdesc="Google Chromebooks with x64 CPU"
pkgver=12
pkgrel=0
url="https://postmarketos.org"
license="MIT"
arch="x86_64"
options="!check !archcheck"
depends="
	alsa-ucm-conf-cros
	depthcharge-tools
	postmarketos-base
	postmarketos-cros-common
	systemd-boot
	"
makedepends="devicepkg-dev"
install="$pkgname.post-install $pkgname.post-upgrade"
subpackages="
	$pkgname-kernel-lts:kernel_lts
	$pkgname-kernel-edge:kernel_edge
	$pkgname-firmware-intel:firmware_intel
	$pkgname-firmware-amd:firmware_amd
	"
source="
	00-amdgpu-firmware.files
	00-i915-firmware.files
	deviceinfo
	modules-initfs
	"
# TODO: package iwlwifi-7265D-29.ucode separetely, so we don't depend
# on linux-firmware-other
_pmb_recommends="
	amd-ucode
	intel-ucode
	linux-firmware-amdgpu
	linux-firmware-i915
	linux-firmware-intel
	linux-firmware-other
	linux-firmware-rtl_nic
	linux-firmware-rtw88
	"

build() {
	devicepkg_build $startdir $pkgname
}

package() {
	devicepkg_package $startdir $pkgname
}

kernel_edge() {
	pkgdesc="Alpine Edge kernel"
	depends="linux-edge"
	devicepkg_subpackage_kernel $startdir $pkgname $subpkgname
}

kernel_lts() {
	pkgdesc="Alpine LTS kernel"
	depends="linux-lts"
	devicepkg_subpackage_kernel $startdir $pkgname $subpkgname
}

firmware_amd() {
	install_if="$pkgname=$pkgver-r$pkgrel linux-firmware-amdgpu"

	install -Dm644 00-amdgpu-firmware.files \
		-t "$subpkgdir"/usr/share/mkinitfs/files-extra
}
firmware_intel() {
	install_if="$pkgname=$pkgver-r$pkgrel linux-firmware-i915"

	install -Dm644 00-i915-firmware.files \
		-t "$subpkgdir"/usr/share/mkinitfs/files-extra
}

sha512sums="
38c53d91a60d0402d4cc5428d65e1e8c26360c481c70b34593b1812c87241c32e91904a3bd31fbfe507f7fdb8b50c909eaad8c4c3a37ca962760567329f7f6ee  00-amdgpu-firmware.files
c17f5c505e0e280a9e51ac1b4264e7703b744fd3831d75ce95f41be4755ae4ccd24b7ca09ba1e236df499a5e748c64a0d2054c9d55d8c8c713fa8c5646ed9a3c  00-i915-firmware.files
514ff5c946633dccaa569fed51743c669ea9942af4dd891ad001ba08bba07fca92503e29304f3eb71c16bc2f2436e1879ff0bf56d99666e4dcf9635c8605da2e  deviceinfo
a6e5a9de9fe010966523606f2fcab1c44004228b4e050f777dcb1160fb3e32cda8096925543522216c2eb354f8ce2f8d4e206d98b077fbd6fb840de94e84c706  modules-initfs
"
